
<div class="content">
        
        <div class="header">
            
            <h1 class="page-title">权限角色列表</h1>
        </div>
        
                  

        <div class="container-fluid">
            <div class="row-fluid">
                    
<div class="btn-toolbar">
    <a href="javascript:;" onclick="append('新增角色','{:U(\'Admin/Role/append\')}','800','400')"><button class="btn btn-primary"><i class="icon-plus"></i>新增角色</button></a>
    
  <div class="btn-group">
  </div>
</div>
<div class="well">
    <table class="table">
      <thead>
        <tr>
          <th style="width: 80px;">#</th>
          <th>角色名称</th>
          <th>角色权限</th>
          <th>角色管理</th>
        </tr>
      </thead>
      <tbody>

        <volist name='roles' id='vo'>
        <tr>
          <!-- <if condition='$vo.status eq 1'>
            <td><span style="background-color: green;color:white;border-radius:10px;padding-left: 10px;padding-right: 10px">已设置</span></td>
          <else/>
            <td><span style="background-color: red;color:white;border-radius:10px;padding-left: 10px;padding-right: 10px">未设置</span></td>
          </if> -->

          <td></td>
          <td>{$vo.role_name}</td>

          <td>
            <volist name='role_auth' id='vol'>
              <if condition="$vo['role_id'] eq $vol['role_id'] and in_array($vol['auth_id'], $au)">
                {$vol.auth_name} | `  
              </if>
            </volist>
          </td>
          <td>
            <!-- <a href="javascript:;" onclick="append('新增管理员','{:U(\'Admin/Proattr/append\',array(\'pro_id\'=>$vo[\'pro_id\']))}','800','400')"><button class="btn btn-primary"><i class="icon-plus"></i></button></a> -->
          
              <a href="javascript:;" onclick="edit('角色属性修改','{:U(\'Admin/Role/edit\',array(\'role_id\'=>$vo[\'role_id\']))}','{$vo.pro_id}','800','400')"><button class="btn btn-primary"><i class="icon-pencil"></i></button></a>
              
              
        
              <a href="javascript:;"  onclick="del_role('{:U(\'Admin/Role/del\')}','{$vo.role_id}')" role="button" data-toggle="modal"><button class="btn btn-primary"><i class="icon-remove"></i></button></a>
          </td>
        </tr>
        </volist>
      
      </tbody>
    </table>
</div>
<div class="pagination">
    <ul>
        {$page}
    </ul>
</div>

<script type="text/javascript">
   function append(title,url,w,h){
      layer_show(title,url,w,h);
   }
   function edit(title,url,id,w,h){
      layer_show(title,url,w,h);
   }

   function del_role(url,role_id){

      layer.confirm('确定要删除吗',function(index){
        $.ajax({
          type:'POST',
          url: url ,
          dataType:'json',
          data:{role_id : role_id},
          success: function(data){
            // alert(data);return false;
            if(data.code==1){

              layer.msg(data.info,{icon:1,time:1000},function(){
                location.href = "{:U('showlist')}";
              });
              
            }else{
              layer.msg(data.info,{icon:2,time:1000});
              return false;
            }
            
          },
          error:function(data){
            
          }

        })
      });
   }

   //搜索
  function sch(obj){

            var search = $(obj);
            var content = search.val();
            // alert(content);return false;
            
            $.ajax({
                  type:'POST',
                  url: '' ,
                  data:{search:content},
                  dataType:'json',
                  success: function(data){
                    // for(var i = 0;i<data.length;i++){
                    //   alert(data[i].status);return false;
                    // }
                    
                    var list = '';
                    for(var i = 0;i<data.length;i++){
                      var append = "append('新增管理员','{:U('Admin/Proattr/append',array('pro_id'=>"+data[i].pro_id+"))}','800','400')";


                      var edit = "edit('产品属性修改','{:U('Admin/Proattr/edit',array('pro_id'=>"+data[i].pro_id+"))}','{$vo.pro_id}','800','400')";

                      var del = "del_attr('del?attr_id="+data[i].pro_id+"')";
                      
                      list += '<tr>';
                      if(data[i].status==1){
                        list +='<td><span style="background-color: green;color:white;border-radius:10px;padding-left: 10px;padding-right: 10px">已设置</span></td><td>';
                      }else{
                        list +='<td><span style="background-color: red;color:white;border-radius:10px;padding-left: 10px;padding-right: 10px">未设置</span></td><td>';
                      }
                      list += data[i].pro_name+'</td><td>'+data[i].catename+'</td><td>'+data[i].create_time+'</td>';
                      
                      list += '<td><a href="javascript:;" onclick="'+append+'"><button class="btn btn-primary"><i class="icon-plus"></i></button></a><a href="javascript:;" onclick="'+edit+'"><button class="btn btn-primary"><i class="icon-pencil"></i></button></a><a href="javascript:;"  onclick="'+del+'" role="button" data-toggle="modal"><button class="btn btn-primary"><i class="icon-remove"></i></button></a></td></tr>';
                    }
                    
                    
                    
                    
                    $('tbody').html(list);
                  },
                  error:function(data){
                    
                  }

            })
       }
   
   
</script>

              